package middleware

import (
	"time"

	"github.com/gin-contrib/cors"
	"github.com/gin-gonic/gin"
)

func Cors() gin.HandlerFunc {
	config := cors.Config{
		AllowMethods: []string{"GET", "POST",
			"PUT", "DELETE", "OPTIONS"},

		AllowHeaders: []string{"Origin",
			"Content-Type", "Authorization"},

		ExposeHeaders:    []string{"Content-Length"},
		AllowCredentials: false,
		MaxAge:           12 * time.Hour,
		AllowAllOrigins:  true,
	}

	return cors.New(config)
}
